from flask import Blueprint, request
from app.models import Patient
from app.utils import custom_jsonify

patient_bp = Blueprint('patient', __name__)

@patient_bp.route('/patient', methods=['GET'])
def get_patient_info_by_name():
    patient_name = request.args.get('name')
    # patient_name = "艾爱国"
    patient = Patient.query.filter_by(patient_name=patient_name).first()
    if patient:
        return custom_jsonify({
            "patient_id": patient.patient_id,
            "patient_name": patient.patient_name,
            "gender": patient.gender,
            "age": patient.age
        }, 200)
    return custom_jsonify({"message": "病人未找到"}, 404)
